package com.longway.common.db.id;

import java.util.HashMap;
import java.util.Map;


public class IdManager {
	
	private static final IdManager me = new IdManager();
	
	private static final String MAIN = "main";
	
	private static Map<String, IIdFactory> idFactorys = new HashMap<String, IIdFactory>();
	
	private IdManager(){}
	
	public static IdManager me(){
		return me;
	}
	
	public void setDefaultIdFactory(IIdFactory defaultIdFactory){
		idFactorys.put(MAIN, defaultIdFactory);
	}
	
	public IIdFactory getDefaultIdFactory(){
		return idFactorys.get(MAIN);
	}
	
	public void addIdFactory(String name,IIdFactory defaultIdFactory){
		idFactorys.put(name, defaultIdFactory);
	}
	
	public IIdFactory getIdFactory(String name){
		return idFactorys.get(name);
	}
}
